package com.jingdianjichi.interview.server.config.websocket;

import com.jingdianjichi.interview.server.utils.LoginUtil;
import org.springframework.stereotype.Component;

import javax.websocket.HandshakeResponse;
import javax.websocket.server.HandshakeRequest;
import javax.websocket.server.ServerEndpointConfig;

/**
 * ClassName:WebSocketServerConfig
 * Package:com.jingdianjichi.circle.server.websocket
 * Description:
 *
 * @Author fst
 * @Create 2025/2/24 16:34
 * @Version 1.0
 */
@Component
public class WebSocketServerConfig extends ServerEndpointConfig.Configurator
{
    @Override
    public boolean checkOrigin(String originHeaderValue)
    {
        return true;
    }

    public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response)
    {
        sec.getUserProperties().put("erp", LoginUtil.getLoginId());
    }
}
